package com.mate.cloud.hot.controller;


import com.mate.cloud.common.response.BaseResponse;
import com.mate.cloud.common.web.controller.AdminBaseController;
import com.mate.cloud.hot.service.HotKeyCacheService;
import com.mate.cloud.hot.service.HotKeyDetectionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @description: java类作用描述
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2025/8/23 19:43
 * @updateUser: MI
 * @updateTime: 2025/8/23 19:43
 * @updateRemark: 修改内容
 * @version: 1.0
 */
@RestController
@RequestMapping("/redis")
@RequiredArgsConstructor
public class RedisHotController extends AdminBaseController {

    private final HotKeyDetectionService hotKeyDetectionService;

    private final HotKeyCacheService hotKeyCacheService;

    @PostMapping("/hotkey")
    public BaseResponse<String> hotkey(@RequestParam String key) {

        return successBodyResponse(hotKeyDetectionService.getWithHotKeyDetection(key));
    }


    @GetMapping("/{key}")
    public BaseResponse get(@PathVariable String key) {
        return successBodyResponse(hotKeyCacheService.getCache(key));
    }

}
